/**
 * 
 */
package com.redside.model.survey;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.redside.model.BaseObject;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * A class to hold Questions related to a com.redside.survey.Survey.
 * @author <a href="mailto:pchapman@easystreet.net">Peter Chapman</a>
 *
 */

@Entity
@Table(name = "question")
public class Question extends BaseObject implements Serializable {

	private static final long serialVersionUID = -5599889685504527354L;

	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "question_id")
    private Long id;
    
    @Column(name="question")
    private String question;
    
    @ManyToOne
    @JoinColumn(name = "survey_id")
    private Survey survey;

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the question
	 */
	public String getQuestion() {
		return question;
	}

	/**
	 * @param question the question to set
	 */
	public void setQuestion(String question) {
		this.question = question;
	}

	/**
	 * @return the survey
	 */
	public Survey getSurvey() {
		return survey;
	}

	/**
	 * @param survey the survey to set
	 */
	public void setSurvey(Survey survey) {
		this.survey = survey;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof Question)) {
			return false;
		}
		Question rhs = (Question) object;
		return new EqualsBuilder().append(this.id, rhs.id).append(this.survey,
				rhs.survey).append(this.question, rhs.question).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-1226438601, 439085769).append(this.id)
				.append(this.survey).append(this.question).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(
				"survey", this.survey).append("question", this.question)
				.append("id", this.id).toString();
	}
}
